package com.zj.rocketmq.demo.repository;

import com.zj.rocketmq.demo.entity.Goods;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface GoodsRepository extends JpaRepository<Goods,Integer> {

    @Query(value = "update goods set stock = stock-1 where id = ?1" ,nativeQuery = true)
    @Modifying
    Integer decrementOfGoods(Integer id);
}
